package de.openkanban.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.widgets.layout.Layout;
import com.smartgwt.client.widgets.layout.VLayout;

import de.openkanban.client.login.LogIn;
import de.openkanban.client.ui.adminpanel.AdminPanel;
import de.openkanban.client.ui.board.BoardView;
import de.openkanban.client.ui.board.WelcomeView;
import de.openkanban.client.ui.footer.Footer;
import de.openkanban.client.util.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 * Initializes the application.
 */
public class Main implements EntryPoint {

	public static final int DEFAULT_FADE_DURATION = 400;

	private Layout layout;
	private AdminPanel adminPanel;
	private BoardView board;
	private WelcomeView welcome;
	private Footer footer;
	private VLayout vlMain = new VLayout();

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		initMain();
		LogIn.initLogin();
	}

	private void initMain() {
		RootPanel.main = this;
		Page.setAppImgDir("[APP]/images/");

		vlMain = new VLayout();

		layout = new VLayout();
		layout.setWidth100();

		adminPanel = new AdminPanel();
		welcome = new WelcomeView();

		vlMain.setSmoothFade(true);
		vlMain.setWidth100();
		vlMain.setHeight100();
		vlMain.setVisible(false);

		layout.addMember(welcome);

		vlMain.addMember(adminPanel);
		vlMain.addMember(layout);

		vlMain.setOverflow(Overflow.HIDDEN);

		vlMain.draw();
	}

	public Layout getLayout() {
		return layout;
	}

	public AdminPanel getAdminPanel() {
		return adminPanel;
	}

	public BoardView getBoard() {
		return board;
	}

	public void setBoard(BoardView board) {
		this.board = board;
	}

	public Footer getFooter() {
		return footer;
	}

	public void setFooter(Footer footer) {
		this.footer = footer;
	}

	public VLayout getVlMain() {
		return vlMain;
	}

	public WelcomeView getWelcome() {
		return welcome;
	}

}
